package com.demo.hotel_book.mapper;

import com.demo.hotel_book.dto.OrderDTO;
import com.demo.hotel_book.entity.Hotel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface OrderZoneMapper {

    /*
     private Integer orderId;
    private Integer price;
    private String phone;
    private String hotelName;
    private String roomCode;
     */
//    room_message.room_id=hotel_order.room_id and *************************暂时不用房间id查
    @Select("select if_pay,order_id,username,price,phone,room_code,hotel_name from hotel_order,room_message" +
            ",hotel_message where hotel_message.hotel_id=room_message.hotel_id and user_id =#{id}")
    List<OrderDTO> listOrdersByUser(int id);

    @Select("select * from hotel_message")
    List<Hotel> listHotel();

    @Update("UPDATE hotel_order SET if_pay = '已支付' WHERE order_id = #{orderId}")
    void updateOrder(String orderId);
}
